package com.hieu.sms.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hieu.sms.model.Clazz;
import com.hieu.sms.model.Course;
import com.hieu.sms.model.CourseScoreFactor;
import com.hieu.sms.model.Department;
import com.hieu.sms.model.Major;
import com.hieu.sms.model.Teacher;
import com.hieu.sms.model.filter.CourseFilter;
import com.hieu.sms.model.filter.TeacherFilter;
import com.hieu.sms.persist.ClazzDao;
import com.hieu.sms.persist.CourseDao;
import com.hieu.sms.persist.CourseScoreFactorDao;
import com.hieu.sms.persist.DepartmentDao;
import com.hieu.sms.persist.MajorDao;
import com.hieu.sms.persist.TeacherDao;

@Service("informationServices")
public class InformationServicesImpl implements InformationServices{
	@Autowired
	private DepartmentDao departmentDao;
	@Autowired
	private MajorDao majorDao;
	
	@Autowired
	private CourseDao courseDao;
	
	@Autowired
	private ClazzDao clazzDao;
	@Autowired
	private CourseScoreFactorDao courseScoreFactorDao;
	
	@Autowired
	private TeacherDao teacherDao;
	
	public List<Department> list() throws Exception{
		return departmentDao.getList();
	}
	public void add(Department department) throws Exception{
		departmentDao.save(department);
	}
	public void delete(Department department)throws Exception{
		departmentDao.delete(department);
	}
	
	public void update(Department department)throws Exception{
		departmentDao.update(department);
	}
	public List<Major> findMajor(String depId) throws Exception{
		return departmentDao.findByDepId(depId);
	}
	public void add(Major major)throws Exception{
		majorDao.save(major);
	}
	public void delete(Major major)throws Exception{
		majorDao.delete(major);
	}
	
	public void add(Course course)throws Exception{
		courseDao.save(course);
	}
	public void update(Course course)throws Exception{
		courseDao.update(course);
	}
	public void delete(Course course)throws Exception{
		courseDao.delete(course);
	}
	
	public List<Course> findCourse(String depId)throws Exception{
		return courseDao.findByDepId(depId);
	}
	
	public List<Course> findCourse(CourseFilter courseFilter)throws Exception{
		return courseDao.search(courseFilter);
	}
	
	
	public void add(Clazz clazz)throws Exception{
		clazzDao.save(clazz);
	}
	public List<Clazz>findClazz(String depId)throws Exception{
		return clazzDao.findByDepId(depId);
	}
	public void delete(Clazz clazz)throws Exception{
		clazzDao.delete(clazz);
	}
	
	
	public List<CourseScoreFactor> findCourseScoreFactor(Course course) throws Exception{
		return courseScoreFactorDao.findByCourse(course);
	}
	public void add(CourseScoreFactor courseScoreFactor)throws Exception{
		courseScoreFactorDao.save(courseScoreFactor);
	}
	public void delete(CourseScoreFactor courseScoreFactor)throws Exception{
		courseScoreFactorDao.delete(courseScoreFactor);
	}
	
	
	public List<Teacher> findTeacher(TeacherFilter filter){
		return teacherDao.findByDepId(filter.getDepId());
	}
	public void add(Teacher teacher){
		teacherDao.save(teacher);
	}
}
